#include <stdio.h>

#define DYN_STR_IMPLEMENTATION
#include "dynamic_string.h"

int main(int argc, char *argv[]) {
    const char *progname = dyn_str_shift_args(&argc, &argv);
    if (argc == 0) {
        printf("Usage: %s <list-of-args-to-test-with>\n", progname);
    }
    String_Builder sb = {0};
    String_View sv = {0};
    while(argc>1) {
        sb_append_cstr(&sb, dyn_str_shift_args(&argc, &argv));
        sb_append_cstr(&sb, ",");
    }
    sb_append_cstr(&sb, dyn_str_shift_args(&argc, &argv));
    sv.length = sb.length;
    sv.data = sb.items;
    printf("Args: "SV_Fmt"\n", SV_Arg(sv));
    printf("Args, chopped:\n");
    String_View item = {0};
    item = sv_chop_by_delim(&sv, ',');
    while(item.length > 0) {
        printf(SV_Fmt"\n", SV_Arg(item));
        item = sv_chop_by_delim(&sv, ',');
    }

    sb_free(sb);
    return 0;
}